<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@page isELIgnored="false" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>驾校查询</title>
</head>
<body>
<div align="center">
    <h2>驾校查询</h2>
    <table border="1" cellspacing="0">

        <select id="xia">

        </select>

        <tbody id="info">

        <tr>
            <td>驾校名称</td>
            <td>所在城区</td>
            <td>地址</td>
            <td>联系电话</td>
            <td>操作</td>
        </tr>


        </tbody>
    </table>
<div id="box"></div>
<%--    <p>一共${p.pages}页</p>--%>
<%--    <a href="info?page=${p.firstPage}">第一页</a>--%>
<%--    <a href="${pageContext.request.contextPath }/info?page=${p.nextPage}">下一页</a>--%>
<%--    <a href="${pageContext.request.contextPath }/info?page=${p.prePage}">上一页</a>--%>
<%--    <a href="${pageContext.request.contextPath }/info?page=${p.lastPage}">最后页</a>--%>
</div>
</body>
</html>
<script src="${pageContext.request.contextPath }/statics/js/jquery-1.8.3.min.js"></script>
<script>
    function getJsonLength(jsonData) {
        var jsonLength = 0;
        for (var item in jsonData) {
            jsonLength++;
        }
        return jsonLength;
    }

    $(function () {

        $.ajax({
            url: "selCityArea",
            type: "get",
            datatype: "json",
            success: function (webResult) {
                if (webResult != null) {
                    for (var i = 0; i <= getJsonLength(webResult); i++) {
                        $("#xia").append("<option value =" + webResult.result.City[i].id + ">" + webResult.result.City[i].name + "</option>")
                    }
                }
            },
            error: function () {
                alert("error");
            }
        });


    });
    $(function () {
        $.ajax({
            url: "selDriverInfo",
            type: "get",
            datatype: "json",
            success: function (web) {
                if (web != null) {
                    var html="";
                    html+='<a href=open?page='+web.result.fy.firstPage+'>首页</a>';
                    html+='<a href=open?page='+web.result.fy.prePage+'>上一页</a>';
                    html+='<a href=open?page='+web.result.fy.nextPage+'>下一页</a>';
                    html+='<a href=open?page='+web.result.fy.lastPage+'>末页</a>';
                    $("#box").append(html);
                    for (var i = 0; i <= getJsonLength(web); i++) {
                        var diqu;
                        if(web.result.DriverSchool[i].cityAreaId==1){
                            diqu="岳麓区";
                        }
                        if(web.result.DriverSchool[i].cityAreaId==2){
                            diqu="开福区";
                        }
                        if(web.result.DriverSchool[i].cityAreaId==3){
                            diqu="天心区";
                        }
                        if(web.result.DriverSchool[i].cityAreaId==4){
                            diqu="雨花区";
                        }
                        $("#info").append("<tr>" +
                            "<td>" + web.result.DriverSchool[i].name + "</td>" +
                            "<td>"+diqu+ "</td>" +
                            "<td>" + web.result.DriverSchool[i].address + "</td>" +
                            "<td>" + web.result.DriverSchool[i].phone + "</td>" +
                            "<td><a href=''>修改</a></td>" +
                            "</tr>")

                    }


                }
            },
            error: function () {
                alert("error");
            }
        });
    });


    // $(function (){
    //
    // })
</script>
